import Mock from 'mockjs';

export default {
  [`GET /api/random`]: (req, res) => {
    console.log('MOCK-GET', req.query);

    const i = Mock.mock('@natural(0,9)');
    const j = Mock.mock('@natural(0,9)');
    res.send({
      formRecord: {
        a: i,
        b: j,
      },
      result: i + j,
    });
  },

  [`POST /api/plus`]: (req, res) => {
    console.log('MOCK-POST', req.body);
    const { formRecord } = req.body;

    res.send({
      formRecord, // formRecord:formRecord
      result: parseInt(formRecord.a, 10) + parseInt(formRecord.b, 10),
    });
  },
};
